﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using DevExpress.Xpo;
using Zero.Core.Domain.Query;
using Zero.DataLayer.Donnees;
using Zero.POCO;
using Zero.POCO.Compagne;
using Zero.POCO.Donnees;
using Zero.POCO.Interfaces;
using Zero.POCO.Views;
using Vague = Zero.POCO.Donnees.Vague;

namespace Zero.DataLayer.Repository
{
    public class FilterRepository : IRepositoryVague<Filter, Guid>
    {
        public Filter FindBy(Guid id)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<Filter> FindAll()
        {

            List<Filter> Modelindiv;


            var config = new AppSettingsReader();

            using (
                var xpoSession = new Session()
                {
                    ConnectionString =
                        ((string)config.GetValue("connect", typeof(string)))
                })
            {
                var Xpoindiv = new XPCollection<XpoFilter>(xpoSession);
                Modelindiv = Xpoindiv.Select(MAP.MapInverse.MapFilter).ToList();
            }

            return Modelindiv;
        }

        public IEnumerable<Filter> FindBy(Query query)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<Filter> FindBy(Query query, int index, int count)
        {
            throw new NotImplementedException();}

        public void SaveAll(IEnumerable<Filter> entities)
        {
            throw new NotImplementedException();
        }

        public List<Filter> FindAll(List<Query> entities)
        {

            throw new NotImplementedException();
        }

        public void Save(Filter entity)
        {

            var config = new AppSettingsReader();
            using (
                var uow = new UnitOfWork()
                    {
                        ConnectionString =
                            ((string)config.GetValue("connect", typeof(string)))
                    })
            {
                var comp = MAP.Map.MapFiltre(entity, uow);
                uow.CommitChanges();
            }
        }

        public void Add(Filter entity)
        {
            throw new NotImplementedException();
        }

        public void Remove(Filter entity)
        {
            throw new NotImplementedException();
        }

        public List<ISignalitique> GetAudienceTv(Query query, Vague signalitique)
        {
            throw new NotImplementedException();
        }

        public List<ISignalitique> GetAudienceRadio(Query query, ISignalitique signalitique)
        {
            throw new NotImplementedException();
        }

        public List<ISignalitique> GetAudiencePresse(Query query, ISignalitique signalitique)
        {
            throw new NotImplementedException();
        }

        public List<ResultatRequete> GetIndicateurRadioTele(Query query, Vague entity)
        {
            throw new NotImplementedException();
        }

        public IEnumerable<ISignalitique> GetSignalitique(Filter Filtre, Vague Vague)
        {
            throw new NotImplementedException();
        }

        public List<AudienceViewModel> GetAudience(Query query, Vague entity)
        {
            throw new NotImplementedException();
        }

        public ProfilView GetStatistiquesProfil(Query query)
        {
            throw new NotImplementedException();
        }

        public ProfilPenetrationView GetStatistiquesProfilPenetration(Query query)
        {
            throw new NotImplementedException();
        }


        public PartAudienceMain GetStatistiquesPartAudience(Query query)
        {
            throw new NotImplementedException();
        }

        public StructureVague GetStatistiquesStructure(Query query)
        {
            throw new NotImplementedException();
        }
    }
}